﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Users;

namespace Sim
{
    public partial class SignUp : Form, ISignUp
    {
        public SignUp()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (EventSignUp == null)
            {
                User u = new User();
                u.firstName = textBoxFirstName.Text;
                u.lastName = textBoxLastName.Text;
                u.age = Convert.ToInt32(textBoxAge.Text);
                u.nation = textBoxNation.Text;
                u.sex = textBoxGender.Text;
                u.level = 0;
                u.username = textBoxUsername.Text;
                u.password = textBoxPassword.Text;
                if (this.EventSignUp(u) == 1)
                {
                    Close();
                    MessageBox.Show("Success!");
                }
                else
                {
                    MessageBox.Show("Please try again you turbonerd.");
                    textBoxUsername.Text = "";
                    textBoxPassword.Text = "";
                }
            }
        }

        public event DelegateSignUp EventSignUp = null;
        
    }
}
